package com.example.androidkt.first


/**
 * 集成 需要open关键字

 */

open class Person {
    var name = ""
    var age = 0
    fun eat() {
        println("name $name , age $age")
    }
}


class Stdent : Person() {
    var sno = ""
    var grade = 0
}

class Stdent1(name: String, age: Int) : Person()

class Stdent2(val par1 :String, val age1: Int) : Person() {
    init {
            println("par $par1")
            println("age1 $age1")
    }
}

interface Study{
    fun readBooks()
    fun doHomeWork(){
        println("不然就会走 Study doHomeWork")
    }
}

class Artist:Study {
    override fun readBooks() {
        println("readBooks")
    }

   /* override fun doHomeWork() {
        println("doHomeWork      如果重写了doHomeWork 就走这里")//不然就会走  println("Study doHomeWork"
    }*/
}

fun doStudy(study: Study){
    study.readBooks()
    study.doHomeWork()
}



fun main() {
    println("---------------------------------------")

    doStudy(Artist())
//    val stdent2 = Stdent2("zhangsan",18)

    println("---------------------------------------")
/*    val person = Person()
    person.name = "hhm"
    person.age = 18
    person.eat()*/
}